/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package object;

/**
 *
 * @author dheath
 */
public class Zbuffer 
{
    float[][] zvalues;
    
    public Zbuffer()
    {
        zvalues = new float[800][800];
        clearZbuffer();
    }
    
    public void clearZbuffer()
    {
        for(int i = 0; i < zvalues.length; i++)
        {
            for(int j = 0; j < zvalues.length; j++)
            {
                zvalues[i][j] = Float.NEGATIVE_INFINITY;
            }
        }
    }
    
    public boolean testAndSet(int x, int y, float z)
    {
        if(z > zvalues[x][y])
        {
            zvalues[x][y] = z;
            //System.out.println(zvalues[x][y]);
            return true;
        }
        else
        {
            //System.out.println("already set!");
            return false;
        }
    }
}
